package com.sourny;

/**
 * @author sourny.yang
 * @date 2018/3/1 17:15
 */
public class UserContext implements AutoCloseable {

    static final ThreadLocal<User> current = new ThreadLocal<User>();

    public UserContext(User user) {
        current.set(user);
    }

    public static User getCurrentUser() {
        return current.get();
    }

    @Override
    public void close() {
        current.remove();
    }
}
